<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"
    />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script src="./js/lib.js"></script>
    <script type="text/javascript" src="./js/jquery.min.js"></script>
    <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">演示</a>
            <a>
                <cite>导航元素</cite>
            </a>
        </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);"
            title="刷新">
            <i class="layui-icon" style="line-height:30px">ဂ</i>
        </a>
    </div>
    <div class="x-body">
        <div class="layui-row">
            <form class="layui-form layui-col-md12 x-so">
                <div class="layui-input-inline">
                    <select name="contrller" id="ptlType" lay-filter="ptlType">
                        <option value="">活动类型</option>
                        <option value="vip">vip 折扣</option>
                        <option value="fullSubtraction">订单满减</option>
                        <option value="discount">普通折扣</option>
                        <option value="deductible">抵扣</option>
                    </select>
                </div>
                <input type="text" id="ptlName" name="ptl_name" placeholder="请输入活动名称" autocomplete="off" class="layui-input">
                <a class="layui-btn" lay-submit="" lay-filter="search" id="search">
                    <i class="layui-icon">&#xe615;</i>
                </a>
            </form>
        </div>
        <xblock>
            <button class="layui-btn" onclick="x_admin_show('添加活动','./promotional-add.htm')">
                <i class="layui-icon"></i>添加</button>
            <span class="x-right" style="line-height:40px">共有数据：<span id="count"></span> 条</span>
        </xblock>
        <table class="layui-table">
            <thead>
                <tr>
                    <th>
                        <div class="layui-unselect header layui-form-checkbox" lay-skin="primary">
                            <i class="layui-icon">&#xe605;</i>
                        </div>
                    </th>
                    <th>活动Id</th>
                    <th>活动名称</th>
                    <th>活动简介</th>
                    <th>活动类型</th>
                    <th>创建管理员</th>
                    <th>创建时间</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody id="t_body">
                
            </tbody>
        </table>
        <div class="page">
            <div>
                <a class="prev" href="">&lt;&lt;</a>
                <a class="num" href="">1</a>
                <span class="current">2</span>
                <a class="num" href="">3</a>
                <a class="num" href="">489</a>
                <a class="next" href="">&gt;&gt;</a>
            </div>
        </div>

    </div>
    <script>
        var ptl_type = undefined;        
        var aId = Cookies.get('kplus-helmetAdminId');
        var aToken = Cookies.get('kplus-helmetAdminToken');
        layui.use(['layer', 'form'], function () {
            var form = layui.form;
            var layer = layui.layer;
            form.on('select(ptlType)', function (data) {
                ptl_type = data.value;
            })

            function getPtlList() {
                var ptl_name = $('#ptlName').val();
                var loadindex1 = layer.load(1, {
                    shade: [0.5, '#000']
                });
                var data = { 'aId': aId, 'aToken': aToken };
                var t_body = $('#t_body');
                if (ptl_type) { data['type'] = ptl_type }
                if (ptl_name) { data['name'] = ptl_name }
                $.ajax({
                    url: bAsEuRl + uRlS.ptl,
                    type: 'GET',
                    data: data,
                    success: function (data) {
                        if (data.msg.code == 200) {
                            var ptl_data = data.data;
                            $('#count').text(ptl_data.length);
                            t_body.empty();
                            for (var i = 0; i < ptl_data.length; i++) {
                                var tr = '<tr>' +
                                    '                    <td>' +
                                    '                        <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id="">' +
                                    '                            <i class="layui-icon">&#xe605;</i>' +
                                    '                        </div>' +
                                    '                    </td>' +
                                    '                    <td>' + ptl_data[i].wPtl + '</td>' +
                                    '                    <td>' + ptl_data[i].ptlName.cn + '</td>' +
                                    '                    <td>' + ptl_data[i].ptlIntro.cn + '</td>' +
                                    '                    <td>' + ptl_data[i].ptlType + '</td>' +
                                    '                    <td>' + ptl_data[i].createAdmin + '</td>' +
                                    '                    <td>' + formatTime(ptl_data[i].formatTime) + '</td>' +
                                    '                    <td>' + TranStatus(ptl_data[i].ptlStatus, '停止', '正常') + '</td>' +
                                    '                    <td class="td-manage">' +
                                    '                        <a title="查看" onclick="x_admin_show(\'查看详情\',\'promotional-detail.html?w_ptl=' + ptl_data[i].wPtl + '\')" href="javascript:;">' +
                                    '                            <i class="layui-icon">&#xe63c;</i>' +
                                    '                        </a>' +
                                    '                    </td>' +
                                    '                </tr>';
                                t_body.append(tr)
                            }
                            layer.close(loadindex1);
                        }
                    },
                    error: function () {
                        layer.close(loadindex1);
                        layer.msg('系统发生严重错误，请联系维护人员')
                    }
                })
            }
            getPtlList();
            $('#search').on('click', function () {
                getPtlList()
            })
        })
        

    </script>
</body>

</html>